﻿<shared:UserControlBase x:Class="HP.Cachalote.WPF.UserControls.TodoLabelTreeViewItemUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:shared="clr-namespace:HP.Cachalote.WPF.Shared"
             xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:galaSoft="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             xmlns:validationRules="clr-namespace:HP.Cachalote.WPF.ValidationRules"
             xmlns:extendedAttachedProperties="clr-namespace:HP.Cachalote.WPF.ExtendedAttachedProperties"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Skins/StoryBoards/TodoLabelTreeViewStoryBoard.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <!--<UserControl.Triggers>
        <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="GridLabelName">
            <BeginStoryboard Storyboard="{StaticResource StoryboardMoveLabelNameForward}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="GridLabelName">
            <BeginStoryboard Storyboard="{StaticResource StoryboardMoveLabelNameBackward}"/>
        </EventTrigger>
    </UserControl.Triggers>-->
    <interactivity:Interaction.Triggers>
        <interactivity:EventTrigger EventName="PreviewMouseLeftButtonDown">
            <interactivity:InvokeCommandAction Command="{Binding ClickCommand}" />
        </interactivity:EventTrigger>
    </interactivity:Interaction.Triggers>
    <Grid x:Name="GridLabelName">
        <Grid.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </Grid.RenderTransform>
        <Grid Visibility="{Binding TodoLabelNameVisibility}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <TextBlock Style="{StaticResource TodoLabelTextBlock}" Text="{Binding Name}" />
            <TextBlock Grid.Column="1" Text="{Binding RelatedTodoItemCount}" Style="{StaticResource TodoItemCountTextBlock}" />
        </Grid>
        <TextBox HorizontalAlignment="Left" Width="150" Style="{StaticResource TodoLabelTextBox}"
                                 Visibility="{Binding TodoLabelNameInputVisibility}" 
                                 extendedAttachedProperties:TextBoxExtendedAttachedProperties.TextBoxController="{Binding}">
            <TextBox.Text>
                <Binding Path="Name" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <validationRules:TodoLabelNameValidationRule />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
            <interactivity:Interaction.Triggers>
                <interactivity:EventTrigger EventName="KeyDown">
                    <galaSoft:EventToCommand Command="{Binding TxtNameOnKeyDownCommand}" PassEventArgsToCommand="True" />
                </interactivity:EventTrigger>
                <interactivity:EventTrigger EventName="LostFocus">
                    <interactivity:InvokeCommandAction Command="{Binding TextBoxNameLostFocusCommand}" />
                </interactivity:EventTrigger>
            </interactivity:Interaction.Triggers>
        </TextBox>
    </Grid>
</shared:UserControlBase>
